#include"address_pool.h"
#include"os_constant.h"
#include"stdio.h"
AddressPool::AddressPool(){}
//设置地址池
void AddressPool::initialize(char* bitmap,const int length,const int startAddress)
{
    resources.initialize(bitmap,length);
    this->startAddress = startAddress;   
}
//从地址池分配count个连续页
int AddressPool::allocate(const int count)
{
    int start = resources.allocate(count);
    // int start = resources.allocate_best_fit(count);
    return (start==-1)?-1:(start*PAGE_SIZE+startAddress);
}
//释放若干页的空间
void AddressPool::release(const int address,const int amount)
{
    resources.release((address-startAddress)/PAGE_SIZE,amount);
}
